home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 2108 / 2108.xpi / content / style.xbl < prev    next >
Extensible Markup Language  |  2009-09-26  |  12KB  |  303 lines

  1. <?xml version="1.0"?>
  2. <!DOCTYPE bindings [
  3.     <!ENTITY % extensionsDTD SYSTEM "chrome://mozapps/locale/extensions/extensions.dtd">
  4.     <!ENTITY % manageDTD SYSTEM "chrome://stylish/locale/manage.dtd">
  5.     <!ENTITY % commonDTD SYSTEM "chrome://stylish/locale/common.dtd">
  6.     %extensionsDTD;
  7.     %manageDTD;
  8.     %commonDTD;
  9. ]>
  10.  
  11. <bindings xmlns="http://www.mozilla.org/xbl" xmlns:xbl="http://www.mozilla.org/xbl" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  12.     <binding id="regular">
  13.         <resources>
  14.             <stylesheet src="chrome://stylish/skin/style.css"/>
  15.         </resources>
  16.         <content>
  17.             <xul:hbox flex="1" context="_child">
  18.                 <xul:vbox>
  19.                     <xul:image anonid="status-icon" ondblclick="document.getBindingParent(this).toggleEnabled()"/>
  20.                     <xul:spacer flex="1"/>
  21.                 </xul:vbox>
  22.                 <xul:vbox flex="1">
  23.                     <xul:label anonid="name" crop="end" xbl:inherits="value=style-name"/>
  24.                     <xul:label anonid="tags" crop="end" xbl:inherits="value=tags"/>
  25.                     <xul:label anonid="id" crop="end" xbl:inherits="value=style-id"/>
  26.                     <xul:label anonid="type" crop="end" xbl:inherits="value=type"/>
  27.                     <xul:deck anonid="actions">
  28.                         <xul:hbox anonid="edit-actions" flex="1">
  29.                             <xul:button anonid="edit" label="&editstyle;" oncommand="document.getBindingParent(this).edit()"/>
  30.                             <xul:spacer flex="1"/>
  31.                             <xul:button anonid="enable" label="&cmd.enable.label;" accesskey="&cmd.enable.accesskey;" oncommand="document.getBindingParent(this).enable()"/>
  32.                             <xul:button anonid="disable" label="&cmd.disable.label;" accesskey="&cmd.disable.accesskey;" oncommand="document.getBindingParent(this).disable()"/>
  33.                             <xul:button anonid="delete" label="&cmd.uninstall.label;" accesskey="&cmd.uninstall2.accesskey;" oncommand="document.getBindingParent(this).delete()"/>
  34.                         </xul:hbox>
  35.                         <xul:hbox anonid="update-actions" flex="1">
  36.                             <xul:label anonid="update-status"/>
  37.                             <xul:spacer flex="1"/>
  38.                             <xul:button anonid="update" label="&update;" accesskey="&update.ak;" style="display:none" oncommand="document.getBindingParent(this).update()"/>
  39.                             <xul:button anonid="update-done" label="&done;" accesskey="&done.ak;" style="display:none" oncommand="document.getBindingParent(this).updateDone()"/>
  40.                         </xul:hbox>
  41.                         <xul:progressmeter anonid="update-progress" mode="undetermined"/>
  42.                     </xul:deck>
  43.                 </xul:vbox>
  44.                 <xul:menupopup>
  45.                     <xul:menuitem anonid="context-edit" label="&editstyle;" oncommand="document.getBindingParent(this).edit()"/>
  46.                     <xul:menuitem anonid="context-enable" label="&cmd.enable.label;" accesskey="&cmd.enable.accesskey;" oncommand="document.getBindingParent(this).enable()"/>
  47.                     <xul:menuitem anonid="context-disable" label="&cmd.disable.label;" accesskey="&cmd.disable.accesskey;" oncommand="document.getBindingParent(this).disable()"/>
  48.                     <xul:menuitem anonid="context-delete" label="&cmd.uninstall.label;" accesskey="&cmd.uninstall2.accesskey;" oncommand="document.getBindingParent(this).delete()"/>
  49.                     <xul:menuitem anonid="homepage" label="&cmd.homepage.label;" accesskey="&cmd.homepage.accesskey;" oncommand="document.getBindingParent(this).visitHomepage()"/>
  50.                     <xul:menuitem anonid="find-update" label="&cmd.checkUpdate.label;" accesskey="&cmd.checkUpdate.accesskey;" oncommand="document.getBindingParent(this).findUpdate()"/>
  51.                 </xul:menupopup>
  52.             </xul:hbox>
  53.         </content>
  54.         <implementation>
  55.             <property name="styleObject"/>
  56.             <constructor>
  57.                 this.reload();
  58.  
  59.                 var that = this;
  60.                 var strings = document.getElementById("extensionsStrings");
  61.                 var strings2 = document.getElementById("stylishStrings");
  62.                 function $(id) {
  63.                     return document.getAnonymousElementByAttribute(that, "anonid", id);
  64.                 }
  65.  
  66.                 // add observers
  67.                 var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
  68.  
  69.                 this.updateCheckStartObserver = {
  70.                     observe: function(subject, topic, data) {
  71.                         if (subject.id != that.styleObject.id) {
  72.                             return;
  73.                         }
  74.                         $("update-done").style.display = "none";
  75.                         $("actions").selectedIndex = 2;
  76.                         that.setAttribute("update", "true");
  77.                     }
  78.                 }
  79.                 observerService.addObserver(this.updateCheckStartObserver, "stylish-style-update-check-start", false);
  80.  
  81.                 this.updateCheckDoneObserver = {
  82.                     observe: function(subject, topic, data) {
  83.                         if (subject.id != that.styleObject.id) {
  84.                             return;
  85.                         }
  86.                         var updateResultMessage;
  87.                         switch (data) {
  88.                             case "no-update-available":
  89.                                 updateResultMessage = strings.getString("noUpdatesMsg");
  90.                                 $("update-done").style.display = "";
  91.                                 setTimeout(function(){that.updateDone()}, 5000);
  92.                                 break;
  93.                             case "no-update-possible":
  94.                                 updateResultMessage = strings2.getString("updateNotPossible");
  95.                                 $("update-done").style.display = "";
  96.                                 setTimeout(function(){that.updateDone()}, 5000);
  97.                                 break;
  98.                             case "update-check-error":
  99.                                 updateResultMessage = strings2.getString("updateCheckError");
  100.                                 $("update-done").style.display = "";
  101.                                 break;
  102.                             case "update-available":
  103.                                 updateResultMessage = strings2.getString("updateAvailable");
  104.                                 $("update-done").style.display = "none";
  105.                                 $("update").style.display = "";
  106.                                 break;
  107.                         }
  108.                         $("update-status").value = updateResultMessage;;
  109.                         $("actions").selectedIndex = 1;
  110.                         that.setAttribute("update", "true");
  111.                     }
  112.                 }
  113.                 observerService.addObserver(this.updateCheckDoneObserver, "stylish-style-update-check-done", false);
  114.  
  115.                 this.updateStartObserver = {
  116.                     observe: function(subject, topic, data) {
  117.                         if (subject.id != that.styleObject.id) {
  118.                             return;
  119.                         }
  120.                         $("update-done").style.display = "none";
  121.                         $("actions").selectedIndex = 2;
  122.                         that.setAttribute("update", "true");
  123.                     }
  124.                 }
  125.                 observerService.addObserver(this.updateStartObserver, "stylish-style-update-start", false);
  126.  
  127.                 this.updateDoneObserver = {
  128.                     observe: function(subject, topic, data) {
  129.                         if (subject.id != that.styleObject.id) {
  130.                             return;
  131.                         }
  132.                         var updateResultMessage;
  133.                         switch (data) {
  134.                             case "no-update-possible":
  135.                                 updateResultMessage = strings.getString("noUpdatesMsg");
  136.                                 break;
  137.                             case "update-failure":
  138.                                 updateResultMessage = strings2.getString("updateFailed");
  139.                                 break;
  140.                             case "update-success":
  141.                                 updateResultMessage = strings2.getString("updateCompleted");
  142.                                 break;
  143.                         }
  144.                         $("update-status").value = updateResultMessage;
  145.                         $("update").style.display = "none"
  146.                         $("update-done").style.display = "";
  147.                         $("actions").selectedIndex = 1;
  148.                         that.setAttribute("update", "true");
  149.                     }
  150.                 }
  151.                 observerService.addObserver(this.updateDoneObserver, "stylish-style-update-done", false);
  152.             </constructor>
  153.             <destructor>
  154.                 this.destroy();
  155.             </destructor>
  156.             <method name="destroy">
  157.                 <body>
  158.                     var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
  159.                     observerService.removeObserver(this.updateCheckStartObserver, "stylish-style-update-check-start");
  160.                     observerService.removeObserver(this.updateCheckDoneObserver, "stylish-style-update-check-done");
  161.                     observerService.removeObserver(this.updateStartObserver, "stylish-style-update-start");
  162.                     observerService.removeObserver(this.updateDoneObserver, "stylish-style-update-done");
  163.                 </body>
  164.             </method>
  165.             <method name="reload">
  166.                 <body>
  167.                     <![CDATA[
  168.                         var that = this;
  169.                         var s = this.styleObject;
  170.                         function $(id) {
  171.                             return document.getAnonymousElementByAttribute(that, "anonid", id);
  172.                         }
  173.  
  174.                         this.setAttribute("style-name", s.name);
  175.                         this.setAttribute("tags", s.getMeta("tag", {}).join(" "));
  176.                         this.setAttribute("type", s.getMeta("type", {}).join(" "));
  177.  
  178.                         $("homepage").disabled = !s.url;
  179.                         $("find-update").disabled = !s.updateUrl;
  180.                         $("context-enable").hidden = s.enabled;
  181.                         $("context-disable").hidden = !s.enabled;
  182.  
  183.                         //isDisabled so we get Firefox's styles, is-disabled so people can still style this (bug 282328)
  184.                         this.setAttribute("is-disabled", !s.enabled);
  185.                         this.setAttribute("isDisabled", !s.enabled);
  186.                     ]]>
  187.                 </body>
  188.             </method>
  189.             <method name="findUpdate">
  190.                 <body>
  191.                     this.styleObject.checkForUpdates();
  192.                 </body>
  193.             </method>
  194.             <method name="update">
  195.                 <body>
  196.                     this.styleObject.applyUpdate();
  197.                 </body>
  198.             </method>
  199.             <method name="delete">
  200.                 <body>
  201.                     stylishCommon.deleteWithPrompt(this.styleObject);
  202.                 </body>
  203.             </method>
  204.             <method name="enable">
  205.                 <body>
  206.                     this.styleObject.enabled = true;
  207.                     this.styleObject.save();
  208.                 </body>
  209.             </method>
  210.             <method name="disable">
  211.                 <body>
  212.                     this.styleObject.enabled = false;
  213.                     this.styleObject.save();
  214.                 </body>
  215.             </method>
  216.             <method name="toggleEnabled">
  217.                 <body>
  218.                     this.styleObject.enabled = !this.styleObject.enabled;
  219.                     this.styleObject.save();
  220.                 </body>
  221.             </method>
  222.             <method name="edit">
  223.                 <body>
  224.                     <![CDATA[
  225.                         stylishCommon.openEditForStyle(this.styleObject);
  226.                     ]]>
  227.                 </body>
  228.             </method>
  229.             <method name="visitHomepage">
  230.                 <body>
  231.                     openURL(this.styleObject.url);
  232.                 </body>
  233.             </method>
  234.             <method name="updateDone">
  235.                 <body>
  236.                     var that = this;
  237.                     function $(id) {
  238.                         return document.getAnonymousElementByAttribute(that, "anonid", id);
  239.                     }
  240.                     $("actions").selectedIndex = 0;
  241.                     this.removeAttribute("update");
  242.                 </body>
  243.             </method>
  244.         </implementation>
  245.         <handlers>
  246.             <handler event="click">
  247.                 var parent = this.parentNode;
  248.                 if (parentNode.nodeName == "style-container")
  249.                     parent = parent.parentNode;
  250.                 if (parent.currentSelection == this)
  251.                     return;
  252.                 if (parent.currentSelection)
  253.                     parent.currentSelection.removeAttribute("selected");
  254.                 parent.currentSelection = this;
  255.                 this.setAttribute("selected", "true");
  256.             </handler>
  257.             <handler event="dblclick">
  258.                 this.edit();
  259.             </handler>
  260.         </handlers>
  261.     </binding>
  262.     <binding id="container">
  263.         <resources>
  264.             <stylesheet src="chrome://stylish/skin/style.css"/>
  265.         </resources>
  266.         <content>
  267.             <xul:vbox flex="1" context="_child">
  268.                 <xul:hbox anonid="heading">
  269.                     <xul:button anonid="twisty" xbl:inherits="label"/>
  270.                 </xul:hbox>
  271.                 <xul:vbox anonid="children">
  272.                     <children/>
  273.                 </xul:vbox>
  274.                 <xul:menupopup>
  275.                     <xul:menuitem anonid="context-enable" label="&cmd.enable.label;" accesskey="&cmd.enable.accesskey;" oncommand="document.getBindingParent(this).enable()"/>
  276.                     <xul:menuitem anonid="context-disable" label="&cmd.disable.label;" accesskey="&cmd.disable.accesskey;" oncommand="document.getBindingParent(this).disable()"/>
  277.                     <xul:menuitem anonid="context-delete" label="&cmd.uninstall.label;" accesskey="&cmd.uninstall2.accesskey;" oncommand="document.getBindingParent(this).delete()"/>
  278.                     <xul:menuitem anonid="find-update" label="&cmd.checkUpdate.label;" accesskey="&cmd.checkUpdate.accesskey;" oncommand="document.getBindingParent(this).findUpdate()"/>
  279.                 </xul:menupopup>
  280.             </xul:vbox>
  281.         </content>
  282.         <implementation>
  283.             <method name="toggle">
  284.                 <body>
  285.                     <![CDATA[
  286.                         if (this.getAttribute("closed") == "true")
  287.                             this.removeAttribute("closed");
  288.                         else
  289.                             this.setAttribute("closed", "true");
  290.                     ]]>
  291.                 </body>
  292.             </method>
  293.         </implementation>
  294.         <handlers>
  295.             <handler event="click">
  296.                 if (event.target != this || event.button != 0)
  297.                     return;
  298.                 this.toggle();
  299.             </handler>
  300.         </handlers>
  301.     </binding>
  302. </bindings>
  303.